package com.glela.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.glela.platform.constant.ErrorEnum;
import com.glela.platform.model.response.ResponseBaseModel;
import com.glela.platform.util.ParameterUtils;
import com.glela.talent.model.request.ActivationTelentRequest;
import com.glela.talent.service.UserDailyLogService;

/**
 * 
 * @author MaoZeYao
 *
 */
@Controller
@RequestMapping("/daily")
public class UserDailyLogController {
	
	private static Logger logger = LoggerFactory.getLogger(UserDailyLogController.class);
	
	@Autowired
	private UserDailyLogService userDailyLogService;

	/**
	 * 增加经验值 签到、分享、推荐新用户注册增加经验值接口
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/operation", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> increaseTalentExperience(@RequestBody ActivationTelentRequest model) {
		try {
			if (ParameterUtils.validParams(model.getUserId(), model.getType())) {
				return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20102), HttpStatus.OK);
			}
			return userDailyLogService.addUserDailyLog(model.getUserId(), model.getType());
		} catch (Exception e) {
			logger.error("异常", e);
			return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20000), HttpStatus.OK);
		}
	}
}
